package org.korifey.ffbdd.api.deprecated;

public class Cache<V> {
	Object[] karr;
	V[] varr;
	
	public Cache(int capacity) {
		karr = new Object[capacity];
		varr = (V[])new Object[capacity];
	}
	
	public boolean contain(Object k) {
		return (k.equals(karr[idx(k)]));
	}
	
	public V get(Object k) {
		return varr[idx(k)];
	}
	
	public void put(Object k, V v) {
		karr[idx(k)] = k;
		varr[idx(k)] = v;
	}
	
	private int idx(Object o) {
		int res = o.hashCode() % karr.length;
		if (res <0) res += karr.length;
		return res;
	}
}
